<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>自定义计数器组件</title>
</head>
<body>
<div id="app">
    <!--每个组件的数据和方法自已保留-->
    <!--每个自定义的标签对应的内容都是独立的-->
    <cpn></cpn>
    <cpn></cpn>
</div>

<template id="counter">
    <h1>{{ count }}</h1>
    <button v-on:click="--count">-</button>
    <button v-on:click="++count">+</button>
</template>

<script type="module">
    import {createApp, defineComponent, ref} from "../../../js/vue.esm-browser.js";

    let counter = defineComponent(
        {
            template: "#counter",
            setup() {
                let count = ref(0)
                return {
                    count,
                };
            }
        }
    )

    let app = createApp(
        {
            setup() {
                return {}
            }
        }
    );

    app.component("cpn", counter)

    app.mount("#app")
</script>
</body>
</html>